Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

fix: Allow using the plugin via symlink #501

Merged
merged 4 commits into from
Apr 23, 2018

Conversation

rosen-vladimirov
Copy link
Contributor

Currently when the plugin is used with symlink, the execution fails as the project dir is calculated incorrectly. Instead of trying to find the project dir, pass it wherever it is required.
This leads to changes in the way NativeScriptAngularCompilerPlugin is loaded - currently it uses the projectDir directly when the plugin is loaded. However, at this point we do no know the exact location of the project directory.
So change the require of the NativeScriptAngularCompilerPlugin to return a function, which accepts projectDir as argument. Expose the loading through a new method in the nativescript-dev-webpack plugin - loadAdditionalPlugins.

PR Checklist

What is the current behavior?

Currently the plugin cannot be used as symlink, as the projectDirectory is calculated incorrectly.

What is the new behavior?

The projectDirectory is not calculated - we know it is exactly where the webpack.config.js is, so we pass it from there to wherever we need it.

Fixes/Implements/Closes #[Issue Number].

BREAKING CHANGE: The current code changes the way NativeScriptAngularCompilerPlugin is loaded. This means that all projects that already have webpack.config.js and just upgrade the version of nativescript-dev-webpack, will not be able to use the plugin (NativeScriptAngularCompilerPlugin). They will have to modify their webpack.config.js files.

Migration steps:
In the webpack.config.js of your application, after requiring the nativescript-dev-webpack plugin, just call

nsWebpack.loadAdditionalPlugins(__dirname);

Currently when the plugin is used with symlink, the execution fails as the project dir is calculated incorrectly. Instead of trying to find the project dir, pass it wherever it is required.
This leads to changes in the way NativeScriptAngularCompilerPlugin is loaded - currently it uses the projectDir directly when the plugin is loaded. However, at this point we do no know the exact location of the project directory.
So change the require of the NativeScriptAngularCompilerPlugin to return a function, which accepts projectDir as argument. Expose the loading through a new method in the nativescript-dev-webpack plugin - `loadAdditionalPlugins`.
BREAKING CHANGE: The current code changes the way NativeScriptAngularCompilerPlugin is loaded. This means that all projects that already have webpack.config.js and just upgrade the version of nativescript-dev-webpack, will not be able to use the plugin (NativeScriptAngularCompilerPlugin). They will have to modify their webpack.config.js files.
@rosen-vladimirov
Copy link
Contributor Author

test

1 similar comment
@dtopuzov
Copy link
Contributor

test

@manoldonev
Copy link
Contributor

test

@SvetoslavTsenov
Copy link
Contributor

test

@manoldonev manoldonev merged commit a7acb4d into master Apr 23, 2018
@manoldonev manoldonev deleted the vladimirov/fix-symlink-plugin branch April 23, 2018 12:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants